// const fs = window.require('fs').promises
const fs = require('fs').promises;
// const path = window.require('path')
const path = require('path'); // 修正此处，使用 Node.js 的 path 模块

const fileHelper = {
  readFile: (filePath) => {
    return fs.readFile(filePath, { encoding: 'utf8'})
  },
  writeFile: (filePath, content) => {
    return fs.writeFile(filePath, content, { encoding: 'utf8'})
  },
  renameFile: (path, newPath) => {
    console.log('重命名成功')
    return fs.rename(path, newPath)
  },
  deleteFile: (path) => {
    return fs.unlink(path)
  }
}

export default fileHelper
